package com.ruoyi.common.constant;

/**
 * 自定义返回码
 *
 * @author admin
 */

public enum ErrorCode {
    /**
     * 系统错误
     */
    ERROR(5000, "error"),

    /**
     * 重试异常code
     */
    RETRY_EXCEPTION_ARTICLE_LIKE_NUM_ADD(601, "文章点赞数量增加重试异常"),
    RETRY_EXCEPTION_ARTICLE_LIKE_NUM_MINUS(602, "文章点赞数量减少重试异常"),
    RETRY_EXCEPTION_ARTICLE_COLLECT_NUM_ADD(603, "文章收藏数量增加重试异常"),
    RETRY_EXCEPTION_ARTICLE_COLLECT_NUM_MINUS(604, "文章收藏数量减少重试异常"),
    RETRY_EXCEPTION_ARTICLE_COMMENT_NUM_ADD(605, "文章评论数量增加重试异常"),
    RETRY_EXCEPTION_ARTICLE_COMMENT_REPLY_NUM_ADD(606, "文章评论回复数量重试异常"),
    RETRY_EXCEPTION_ARTICLE_VITALITY_ADD(607, "文章活力值重试异常"),
    RETRY_EXCEPTION_ARTICLE_COMMENT_LIKE_NUM_ADD(608, "文章评论点赞数量增加重试异常"),
    RETRY_EXCEPTION_ARTICLE_COMMENT_LIKE_NUM_MINUS(609, "文章评论点赞数量减少重试异常"),
    RETRY_EXCEPTION_ARTICLE_COMMENT_REPLY_LIKE_NUM_ADD(610, "文章回复点赞数量增加重试异常"),
    RETRY_EXCEPTION_ARTICLE_COMMENT_REPLY_LIKE_NUM_MINUS(611, "文章回复点赞数量减少重试异常"),
    RETRY_EXCEPTION_ACTIVITY_COLLECT_NUM_ADD(612, "活动收藏数量增加重试异常"),
    RETRY_EXCEPTION_ACTIVITY_COLLECT_NUM_MINUS(613, "活动收藏数量减少重试异常"),
    RETRY_EXCEPTION_ACTIVITY_VITALITY_ADD(614, "活动活力值重试异常"),
    RETRY_EXCEPTION_ABROAD_APPLICATION_LIKE_NUM_ADD(615, "留学申请文章点赞数量增加重试异常"),
    RETRY_EXCEPTION_ABROAD_APPLICATION_LIKE_NUM_MINUS(616, "留学申请文章点赞数量减少重试异常"),
    RETRY_EXCEPTION_TOURISM_COLLECT_NUM_ADD(617, "旅游收藏数量增加重试异常"),
    RETRY_EXCEPTION_TOURISM_COLLECT_NUM_MINUS(618, "旅游收藏数量减少重试异常"),
    RETRY_EXCEPTION_TOURISM_VITALITY_ADD(619, "旅游活力值增加重试异常"),
    RETRY_EXCEPTION_MEMBER_INTEGRAL_ADD(620, "用户积分增加重试异常"),
    RETRY_EXCEPTION_MEMBER_INTEGRAL_MINUS(621, "用户积分减少重试异常"),
    RETRY_EXCEPTION_ACTIVITY_SIGNUP_NUM_ADD(622, "活动报名人数增加重试异常"),
    RETRY_EXCEPTION_ACTIVITY_SIGNUP_NUM_MINUS(623, "活动报名人数减少重试异常"),
    RETRY_EXCEPTION_TOURISM_SIGNUP_NUM_ADD(624, "旅游报名人数增加重试异常"),
    RETRY_EXCEPTION_TOURISM_SIGNUP_NUM_MINUS(625, "旅游报名人数减少重试异常"),
    RETRY_EXCEPTION_DYNAMIC_LIKE_NUM_ADD(626, "动态点赞数量增加重试异常"),
    RETRY_EXCEPTION_DYNAMIC_LIKE_NUM_MINUS(627, "动态点赞数量减少重试异常"),
    RETRY_EXCEPTION_DYNAMIC_COMMENT_NUM_ADD(628, "动态评论数量增加重试异常"),
    RETRY_EXCEPTION_DYNAMIC_COMMENT_REPLY_NUM_ADD(629, "动态评论回复数量增加重试异常"),
    RETRY_EXCEPTION_DYNAMIC_COMMENT_LIKE_NUM_ADD(630, "动态评论点赞数量增加重试异常"),
    RETRY_EXCEPTION_DYNAMIC_COMMENT_LIKE_NUM_MINUS(631, "动态评论点赞数量减少重试异常"),
    RETRY_EXCEPTION_DYNAMIC_COMMENT_REPLY_LIKE_NUM_ADD(632, "动态回复点赞数量增加重试异常"),
    RETRY_EXCEPTION_DYNAMIC_COMMENT_REPLY_LIKE_NUM_MINUS(633, "动态回复点赞数量减少重试异常"),
    RETRY_EXCEPTION_ABROAD_APPLICATION_COMMENT_NUM_ADD(634, "留学申请评论数量增加重试异常"),
    RETRY_EXCEPTION_ABROAD_APPLICATION_COLLECT_NUM_ADD(635, "留学申请收藏数量增加重试异常"),
    RETRY_EXCEPTION_ABROAD_APPLICATION_COLLECT_NUM_MINUS(636, "留学申请收藏数量减少重试异常"),
    ;


    private int code;
    private String message;

    ErrorCode() {
    }

    private ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ErrorCode getResultEnum(int code) {
        for (ErrorCode type : ErrorCode.values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        return ERROR;
    }

    public static ErrorCode getResultEnum(String message) {
        for (ErrorCode type : ErrorCode.values()) {
            if (type.getMessage().equals(message)) {
                return type;
            }
        }
        return ERROR;
    }


    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }


}
